package com.myspace.backend.service.impl.user;

import com.myspace.backend.mapper.UserMapper;
import com.myspace.backend.pojo.User;
import com.myspace.backend.service.user.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class UserInfoServiceImpl implements UserInfoService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public Map<String, String> getUserinfo(String userId) {

        int id = Integer.parseInt(userId);
        User user = userMapper.selectById(userId);
        Map<String, String> map = new HashMap<>();
        map.put("error_message", "success");
        map.put("id", user.getId().toString());
        map.put("username", user.getUsername());
        map.put("photo", user.getPhoto());
        map.put("followerCount", user.getFollowerCount().toString());
        map.put("is_followed", "false");

        return map;
    }
}
